package com.example.business.entity;

import com.alibaba.fastjson.JSONObject;
import lombok.Data;

/**
 * Created by ASUS on 2021/6/29.
 */
@Data
public class Result<T> {
    private String code;
    private String msg;
    private T data;

    public Result(String code, String msg, T data){
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static JSONObject success(Object data){
        JSONObject jo = new JSONObject();
        jo.put("code", "000000");
        jo.put("msg", "SUCCESS");
        jo.put("data", data);
        return jo;
    }

    public static JSONObject error(String code, String msg){
        JSONObject jo = new JSONObject();
        jo.put("code", code);
        jo.put("msg", msg);
        return jo;
    }


}
